package algorithmus.distance;

import data.DataSetInterface;

public class EuclidianDistance {
	private double squaredDistance =0;
	private double distance;
	private double[] xObject;
	private double[] yObject;
	private int dimension;

	public EuclidianDistance(double[] x, double[] y) {
		if (x.length != y.length) {
			System.out.println("The lengths of the two objects must be equal.");
		} else {
			this.dimension = x.length;
		}
		this.xObject = x;
		this.yObject = y;
		for (int i = 0; i < this.dimension; i++) {
			this.squaredDistance += Math.pow((xObject[i] - yObject[i]), 2);
		}
		this.distance=Math.sqrt(this.squaredDistance);
	}

	public void showDistance(){
		System.out.println("The distance is: " + this.distance);
		System.out.println("The squared distance is: "+ this.squaredDistance);
	}
}
